<?php
namespace Admin\Controller;
use Common\Controller\BaseController;
class PublicController extends BaseController{

	//登录页面
	public function login(){
		if(!session('uid'))
			$this->display();
		else
			$this->redirect('Index/index');
	}
	//验证码
	public function verify(){
		$verify= new \Think\Verify;
		$verify->entry();
	}
	//登入
	public function checkin(){
		
	$verify= new \Think\Verify;
	if(!$verify->check(I('verify')))
		$this->error(L("invalid_verify"));
		
    $oop=M('member');
	$map['account'] = $_POST['username'];
	$map['status']=1;
	$authInfo = $oop->where($map)->find();

        //使用用户名、密码和状态的方式进行认证
        if(!$authInfo)
            $this->error(L("no_account"));

        if($authInfo['password'] != md5($_POST['password']))
				$this->error(L("error_pwd"));
	
	session("uid",$authInfo['id']);					
	//dump($_SESSION);exit;
	$authInfo['last_login_time']=date('Y-m-d H:i:s');
	$authInfo['last_login_ip']=get_client_ip();
	$authInfo['login_count']++;
	$oop->save($authInfo);
    $this->success(L("checkin_success"));
	
	}
	
	//登出
	public function logout(){
		session(null);
		$this->success(L("checkout_success"),U('Public/login'));
	}
}
?>